package com.smart.order.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smart.order.entity.Order;

/**
 * 在取消订单的时候    1.取消  2.用户支付了怎么办? 业务问题? 技术问题?
 */
public interface OrderMapper extends BaseMapper<Order> {
    /**
     * @param orderSn
     * @return
     */
    default int updateOrderStatusBySn(String orderSn) {
        Order order = new Order();
        order.setStatus(6);
        LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Order::getOrderSn, orderSn).eq(Order::getStatus, 1);
        return this.update(order, queryWrapper);
    }
}